#pragma once

#include <string>
#include <vector>
#include <memory>

#ifdef _WIN32
#define DEMO_LIB_BUILD
#endif
// 平台特定的导出宏
#ifdef _WIN32
    #ifdef DEMO_LIB_BUILD
        #define DEMO_API __declspec(dllexport)
    #else
        #define DEMO_API __declspec(dllimport)
    #endif
#else
    #define DEMO_API
#endif

class DemoDAOImpl;  // 前向声明实现类

class DEMO_API DemoDAO {
private:
    std::unique_ptr<DemoDAOImpl> pImpl;

public:
    explicit DemoDAO(const std::string& conn_str);
    virtual ~DemoDAO();

    // 禁止拷贝
    DemoDAO(const DemoDAO&) = delete;
    DemoDAO& operator=(const DemoDAO&) = delete;

    // 允许移动
    DemoDAO(DemoDAO&&) noexcept;
    DemoDAO& operator=(DemoDAO&&) noexcept;

    // 数据库操作接口
    bool createTable();
    int insertData(const std::string& data);
    void batchInsert(const std::vector<std::string>& dataList);
    void selectAll();
    void selectById(int id);
    bool updateData(int id, const std::string& newData);
    bool deleteData(int id);
    bool isConnected() const;
    bool reconnect();
    std::string getLastError() const;
};